
* *********************************************************************
*
*  Generate "SeqNum" which is the sequence number of the case from
*    the original data set. 
*    Sometimes we have to sort for analyses.
*    In case we have to rebuild, we can match-merge 
*      with the identical case order.
*
* *********************************************************************

gen SeqNum=_n
  label variable SeqNum "Sequence Number: Original Data Set"
*
* *********************************************************************
* Create new Story Variable
* *********************************************************************

gen Story=xstory 
  label variable Story "Story Stimulus"
  label define Story_lb 1 "TerrorANX" 2 "GoodNewsENT" 3 "BinLadenAVR"
  label value Story Story_lb

* *********************************************************************
*  Create new method variable
* *********************************************************************


gen Method=xscale 
  label variable Method "Affect Measure"
  label define Method_lb 1 "radio button" 2 "slider" 3 "slider IS" 4 "slider RBL"
  label value Method Method_lb

*
* *********************************************************************
*
*  Build up new "English Language" named variables
*    from the Knowledge Networks "q.." names
*    (Translate "-1" refusals to "." missing data
*
* *********************************************************************
*
*
* *********************************************************************
*	create english named affect items; affectRB for radio button
*	affectSL for sliders
*	affectSLIS for sliders with instruction set after prompts
*
***********************************************************************

gen byte scaredRB=q1_2 
  replace scaredRB=. if scaredRB<0
  label variable scaredRB "scaredRB"
  label values scaredRB q1_2
gen byte enthusiasticRB=q2_2 
  replace enthusiasticRB=. if enthusiasticRB<0
  label variable enthusiasticRB "enthusiasticRB"
  label values enthusiasticRB q2_2
gen byte hatefulRB=q3_2 
  replace hatefulRB=. if hatefulRB<0
  label variable hatefulRB "hatefulRB"
  label values hatefulRB q3_2
gen byte worriedRB=q4_2 
  replace worriedRB=. if worriedRB<0
  label variable worriedRB "worriedRB"
  label values worriedRB q4_2
gen byte hopefulRB=q5_2 
  replace hopefulRB=. if hopefulRB<0
  label variable hopefulRB "hopefulRB"
  label values hopefulRB q5_2
gen byte angryRB=q6_2 
  replace angryRB=. if angryRB<0
  label variable angryRB "angryRB"
  label values angryRB q6_2
gen byte proudRB=q7_2 
  replace proudRB=. if proudRB<0
  label variable proudRB "proudRB"
  label values proudRB q7_2
gen byte bitterRB=q8_2 
  replace bitterRB=. if bitterRB<0
  label variable bitterRB "bitterRB"
  label values bitterRB q8_2
gen byte resentfulRB=q9_2 
  replace resentfulRB=. if resentfulRB<0
  label variable resentfulRB "resentfulRB"
  label values resentfulRB q9_2
gen byte afraidRB=q10_2 
  replace afraidRB=. if afraidRB<0
  label variable afraidRB "afraidRB"
  label values afraidRB q10_2
gen byte scaredSL=q1_1 
  label variable scaredSL "scaredSL"
  label values scaredSL q1_1
gen byte enthusiasticSL=q2_1 
  label variable enthusiasticSL "enthusiasticSL"
  label values enthusiasticSL q1_2
gen byte hatefulSL=q3_1
  label variable hatefulSL "hatefulSL"
  label values hatefulSL q3_1
gen byte worriedSL=q4_1 
  label variable worriedSL "worriedSL"
  label values worriedSL q4_1
gen byte hopefulSL=q5_1 
  label variable hopefulSL "hopefulSL"
  label values hopefulSL q5_1
gen byte angrySL=q6_1
  label variable angrySL "angrySL"
  label values angrySL q6_1
gen byte proudSL=q7_1
  label variable proudSL "proudSL"
  label values proudSL q7_1
gen byte bitterSL=q8_1
  label variable bitterSL "bitterSL"
  label values bitterSL q8_1
gen byte resentfulSL=q9_1
  label variable resentfulSL "resentfulSL"
  label values resentfulSL q9_1
gen byte afraidSL=q10_1
  label variable afraidSL "afraidSL"
  label values afraidSL q10_1
gen byte scaredSLALL=q1_1_reconsider 
  replace scaredSLALL=scaredSL if scaredSLALL==.
  label variable scaredSLALL "scared"
  label values scaredSLALL q1_1_reconsider
gen byte enthusiasticSLALL=q2_1_reconsider
  replace enthusiasticSLALL=enthusiasticSL if enthusiasticSLALL==. 
  label variable enthusiasticSLALL "enthusiastic"
  label values enthusiasticSLALL q2_1_reconsider
gen byte hatefulSLALL=q3_1_reconsider
  replace hatefulSLALL=hatefulSL if hatefulSLALL==.
  label variable hatefulSLALL "hateful"
  label values hatefulSLALL q3_1_reconsider
gen byte worriedSLALL=q4_1_reconsider
  replace worriedSLALL=worriedSL if worriedSLALL==.
  label variable worriedSLALL "worried"
  label values worriedSLALL q4_1_reconsider
gen byte hopefulSLALL=q5_1_reconsider
  replace hopefulSLALL=hopefulSL if hopefulSLALL==.
  label variable hopefulSLALL "hopeful"
  label values hopefulSLALL q5_1_reconsider
gen byte angrySLALL=q6_1_reconsider
  replace angrySLALL=angrySL if angrySLALL==.
  label variable angrySLALL "angry"
  label values angrySLALL q6_1_reconsider
gen byte proudSLALL=q7_1_reconsider 
  replace proudSLALL=proudSL if proudSLALL==.
  label variable proudSLALL "proud"
  label values proudSLALL q7_1_reconsider
gen byte bitterSLALL=q8_1_reconsider
  replace bitterSLALL=bitterSL if bitterSLALL==.
  label variable bitterSLALL "bitter"
  label values bitterSLALL q8_1_reconsider
gen byte resentfulSLALL=q9_1_reconsider
  replace resentfulSLALL=resentfulSL if resentfulSLALL==.
  label variable resentfulSLALL "resentful"
  label values resentfulSLALL q9_1_reconsider
gen byte afraidSLALL=q10_1_reconsider 
  replace afraidSLALL=afraidSL if afraidSLALL==.
  label variable afraidSLALL "afraid"
  label values afraidSLALL q10_1_reconsider
gen scared=scaredSLALL/100
  replace scared=0.25*(scaredRB-1) if scaredSLALL==.
  label variable scared "scared01"
gen enthusiastic=enthusiasticSLALL/100
  replace enthusiastic=0.25*(enthusiasticRB-1) if enthusiasticSLALL==.
  label variable scared "enthusiastic01"
gen hateful=hatefulSLALL/100
  replace hateful=0.25*(hatefulRB-1) if hatefulSLALL==.
  label variable scared "hateful01"
gen worried=worriedSLALL/100
  replace worried=0.25*(worriedRB-1) if worriedSLALL==.
  label variable scared "worried01"
gen hopeful=hopefulSLALL/100
  replace hopeful=0.25*(hopefulRB-1) if hopefulSLALL==.
  label variable scared "hopeful01"
gen angry=angrySLALL/100
  replace angry=0.25*(angryRB-1) if angrySLALL==.
  label variable angry "angry01"
gen proud=proudSLALL/100
  replace proud=0.25*(proudRB-1) if proudSLALL==.
  label variable scared "proudd01"
gen bitter=bitterSLALL/100
  replace bitter=0.25*(bitterRB-1) if bitterSLALL==.
  label variable scared "bitter01"
gen resentful=resentfulSLALL/100
  replace resentful=0.25*(resentfulRB-1) if resentfulSLALL==.
  label variable resentful "resentful01" 
gen afraid=afraidSLALL/100
  replace afraid=0.25*(afraidRB-1) if afraidSLALL==.
  label variable afraid "afraid01"


* *********************************************************************
*
*  Attention Variables
*
* *********************************************************************


gen byte mentalnote=q2_revised 
  replace mentalnote=. if mentalnote<0
  label variable mentalnote "Mental Note"
  label values mentalnote q2_revised
gen byte google=q3_revised 
  replace google=. if google<0
  label variable google "Googling"
  label values google q3_revised
gen byte searchweb=q4_revised 
  replace searchweb=. if searchweb<0
  label variable searchweb "Look web new and different views "
  label values searchweb q4_revised
gen byte challengeme=q5_revised 
  replace challengeme=. if challengeme<0
  label variable challengeme "Look web site challenge my views"
  label values challengeme q5_revised
gen byte disagreestuff=q6_revised 
  replace disagreestuff=. if disagreestuff<0
  label variable disagreestuff "Look web sites which I strongly disagree "
  label values disagreestuff q6_revised

* *********************************************************************
*
*  StandPat and Cooperative Variables
*
* *********************************************************************
*

gen byte nocompromise=q9
  replace nocompromise=. if nocompromise<0
  label variable nocompromise "No compromise"
  label values nocompromise q9
gen byte rightone=q10
  replace rightone=. if rightone<0
  label variable rightone "Right One"
  label values rightone q10
gen byte listeneveryone=q11
  replace listeneveryone=. if listeneveryone<0
  label variable listeneveryone "Listen Everyone"
  label values listeneveryone q11
gen byte twosides=q13
  replace twosides=. if twosides<0
  label variable twosides "Two Sides"
  label values twosides q13
gen byte resolveeveryone=q14
  replace resolveeveryone=. if resolveeveryone<0
  label variable resolveeveryone "Resolve Everyone"
  label values resolveeveryone q14
gen byte everyoneconcerns=q15
  replace everyoneconcerns=. if everyoneconcerns<0
  label variable everyoneconcerns "Everyone Concerns"
  label values everyoneconcerns q15

*
* *********************************************************************
*
*  Build emotional response variables
*    Capital letters (ANXIETY) are used for "latent variables"
*    Note the coding has the high scores identified with more emotion
*	 each underlying item has the same 0-1 range
*      
*
* *********************************************************************

egen ANXIETY=rmean(scared worried afraid)
  label variable ANXIETY "Anxiety Scale"

egen ENTHUSIASM=rmean(enthusiastic hopeful proud)
 label variable ENTHUSIASM "Enthusiasm Scale"

egen AVERSION_ACTIVE=rmean(hateful angry)
  label variable AVERSION_ACTIVE "Aversion (Active) Scale"

egen AVERSION_PASSIVE=rmean(bitter resentful)
  label variable AVERSION_PASSIVE "Aversion (Passive) Scale"

egen AVERSION=rmean(hateful angry bitter resentful)
  label variable AVERSION "Aversion Scale"
  
*
* *********************************************************************
*
*  CREATE TWO SCALES for "StandPat" and "Compromise"
*
* *********************************************************************

* Now create the two scales as simple means over the variables
*   (and set direction and 0-1 range)
*  NOTE THAT SOME ITEMS ARE NOW REVERSED TO MAKE NATURAL SENSE


egen StandPat=rmean(nocompromise rightone listeneveryone)
  replace StandPat=(5-StandPat)/4
  label variable StandPat "Stand Pat"

egen Cooperate=rmean(twosides resolveeveryone everyoneconcerns) 
  replace Cooperate=(5-Cooperate)/4
  label variable Cooperate "Cooperate"

*
*
* *********************************************************************
*
*  CREATE TWO SHORT SCALES for "StandPat" and "Compromise"
*
* *********************************************************************

egen StandPat2=rmean(rightone listeneveryone)
  replace StandPat2=(5-StandPat2)/4
  label variable StandPat2 "Stand Pat 2 item"

egen Cooperate2=rmean(resolveeveryone everyoneconcerns) 
  replace Cooperate2=(5-Cooperate2)/4
  label variable Cooperate2 "Cooperate 2 item"


* *********************************************************************
*
*  Create ATTENTION scale
*
* *********************************************************************
*
egen ATTENTION=rmean(mentalnote google searchweb challengeme disagreestuff)
  replace ATTENTION = (ATTENTION-1)/4
  label variable ATTENTION "Attention scale"
  
egen ATTENTIONs=rmean(google searchweb challengeme disagreestuff)
  replace ATTENTIONs = (ATTENTIONs-1)/4
  label variable ATTENTIONs "Short Attention scale"

*
** *********************************************************************
*
* Risk Aversion Items
*
* *********************************************************************
*
gen byte actboldly=q15a
  replace actboldly=. if actboldly<0
  label variable actboldly "Act Boldly"
  label values actboldly q15a
gen byte likeexciting=q15b
  replace likeexciting=. if likeexciting<0
  label variable likeexciting "Exicitting Experiences"
  label values likeexciting q15b
gen byte excitefriends=q15c
  replace excitefriends=. if excitefriends<0
  label variable excitefriends "Exicitting Friends"
  label values excitefriends q15c
gen byte difficultfriends=q15d
  replace difficultfriends=. if difficultfriends<0
  label variable difficultfriends "Difficult Making Friends"
  label values difficultfriends q15d
*
*
**********************************************************************
*
* Reverse code appropriate Risk Aversion Item prior to scaling
*
**********************************************************************
*
generate difficultfriendsR = (5 - difficultfriends)

*
*
* *********************************************************************
*
*  Risk AVersion Scale
*
* *********************************************************************
*
egen RiskAversion=rmean(actboldly likeexciting excitefriends difficultfriendsR)
  replace RiskAversion=(5-RiskAversion)/4
  label variable RiskAversion "Risk Aversion"
  
  
* *********************************************************************
*
*  Short 3 Item Risk AVersion Scale
*
* *********************************************************************
*
egen RiskAversion3=rmean(likeexciting excitefriends difficultfriendsR)
  replace RiskAversion3=(5-RiskAversion3)/4
  label variable RiskAversion3 "Risk Aversion 3 item"

* *********************************************************************
*
*  Need for Cognition items
*
* *********************************************************************
*
gen byte prefercomplex=q18
  replace prefercomplex=. if prefercomplex<0
  label variable prefercomplex "Prefer Complex"
  label values prefercomplex q18
gen byte thinknotfun=q19
  replace thinknotfun=. if thinknotfun<0
  label variable thinknotfun "Thinking not Fun"
  label values thinknotfun q19
gen byte deliberatehard=q20
  replace deliberatehard=. if deliberatehard<0
  label variable deliberatehard "Deliberate Hard"
  label values deliberatehard q20
gen byte onlythink=q21
  replace onlythink=. if onlythink<0
  label variable onlythink "Only  Think"
  label values onlythink q21
gen byte deliberating=q23
  replace deliberating=. if deliberating<0
  label variable deliberating "End up Deliberating"
  label values deliberating q23
  
***********************************************************************
*
* Reverse code appropriate Need for Cognition Items prior to scaling
*
**********************************************************************
*
generate thinknotfunR = (5 - thinknotfun)
generate onlythinkR = (5 - onlythink)

*  
* *********************************************************************
*
*  Need for Cognition Scale
*
* *********************************************************************

egen NeedforCognition=rmean(prefercomplex thinknotfunR deliberatehard onlythinkR deliberating)
  replace NeedforCognition=(5-NeedforCognition)/4
  label variable NeedforCognition "Need for Cognition"


* *********************************************************************
*
*  Big Five items
*
* *********************************************************************
*
gen byte Reserved=q23a
  replace Reserved=. if Reserved<0
  label variable Reserved "Reserved"
  label values Reserved q23a
gen byte Trusting=q23b
  replace Trusting=. if Trusting<0
  label variable Trusting "Trusting"
  label values Trusting q23b
gen byte Lazy=q23c
  replace Lazy=. if Lazy<0
  label variable Lazy "Lazy"
  label values Lazy q23c
gen byte Relaxed=q23d
  replace Relaxed=. if Relaxed<0
  label variable Relaxed "Relaxed"
  label values Relaxed q23d
gen byte FewArtistic=q23e
  replace FewArtistic=. if FewArtistic<0
  label variable FewArtistic "Few Artistic Interests"
  label values FewArtistic q23e
gen byte Outgoing=q23f
  replace Outgoing=. if Outgoing<0
  label variable Outgoing "Outgoing"
  label values Outgoing q23f
gen byte FindFault=q23g
  replace FindFault=. if FindFault<0
  label variable FindFault "Finds Fault"
  label values FindFault q23g
gen byte Thorough=q23h
  replace Thorough=. if Thorough<0
  label variable Thorough "Thorough Job"
  label values Thorough q23h
gen byte Nervous=q23i
  replace Nervous=. if Nervous<0
  label variable Nervous "Nervous"
  label values Nervous q23i
gen byte Imaginative=q23j
  replace Imaginative=. if Imaginative<0
  label variable Imaginative "Imaginative"
  label values Imaginative q23j


*
* *********************************************************************
*
*      Big Five Scales
*
* *********************************************************************
*
generate Extraversion = ((Outgoing - 1) + (5 - Reserved))/8
generate Agreeableness = ((5 - FindFault) + (Trusting - 1))/8
generate Conscientiousness = ((Thorough - 1) + (5 - Lazy))/8
generate Neuroticism = ((5 - Relaxed) + (Nervous - 1))/8
generate OpennessExperience = ((Imaginative - 1) + (5 - FewArtistic))/8

*
*********************************************************************
*
* Build PartyID - Dem = high
* rescale to 0-1 range
*
*********************************************************************
generate PartyID=q16
  replace PartyID=. if q16 ==-1
  replace PartyID=1 if q16 ==1
  replace PartyID=2 if q16 ==2
  replace PartyID=3 if q16 ==3
  replace PartyID=4 if q16 ==4
  replace PartyID=5 if q16 ==5
  replace PartyID=6 if q16 ==6
  replace PartyID=7 if q16 ==7
  replace PartyID=. if q16 ==-0
  replace PartyID=(PartyID - 1)/6

*********************************************************************
*
* Build Ideology - left = high
* rescale to 0-1 range
*
*********************************************************************

generate Ideology=q17
  replace Ideology=. if q17 ==-1
  replace Ideology=1 if q17 ==1
  replace Ideology=2 if q17 ==2
  replace Ideology=3 if q17 ==3
  replace Ideology=4 if q17 ==4
  replace Ideology=5 if q17 ==5
  replace Ideology=6 if q17 ==6
  replace Ideology=7 if q17 ==7
  replace Ideology=. if q17 ==-0
  replace Ideology=(Ideology - 1)/6
*********************************************************************
*
* relabel to get Age7 = 7 categories
*
*********************************************************************
generate Age7=ppagecat
*********************************************************************
*
* relabel to get Age4 = 4 categories
*
*********************************************************************
generate Age4=ppagect4
*********************************************************************
*
* relabel to get Education = 4 categories
*
*********************************************************************
generate Education=ppeducat
*********************************************************************
*
* relabel to get Gender = 2 categories - 1 = male; 2 = female
*
*********************************************************************
generate Gender=ppgender
*********************************************************************
*
* relabel to get Household Income
*
*********************************************************************
generate HouseInc=ppincimp

exit
